﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Swsk33.SimpleArcEngine.Dialog
{
	public partial class OpenDatasetDialog : Form
	{
		/// <summary>
		/// 所选的数据集
		/// </summary>
		private string selectedDataSet = "";

		public OpenDatasetDialog()
		{
			InitializeComponent();
		}

		/// <summary>
		/// 显示选择数据集文件窗口
		/// </summary>
		/// <param name="dataSetNamesList">全部数据集名</param>
		public string OpenShapeFileDialog(List<string> dataSetNamesList)
		{
			foreach (string name in dataSetNamesList)
			{
				dataSetNames.Items.Add(name);
			}
			ShowDialog();
			return selectedDataSet;
		}

		private void ok_Click(object sender, EventArgs e)
		{
			if (dataSetNames.SelectedIndex < 0)
			{
				MessageBox.Show("请选择一个数据集！", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
				return;
			}
			selectedDataSet = dataSetNames.SelectedItem.ToString();
			Close();
		}

		private void cancel_Click(object sender, EventArgs e)
		{
			selectedDataSet = "";
			Close();
		}

		private void shpNames_DoubleClick(object sender, EventArgs e)
		{
			selectedDataSet = dataSetNames.SelectedItem.ToString();
			Close();
		}
	}
}